Patrick Ryan's profile

Light Mask Shader

One of the shaders I needed to add to my toolbox was a shader that masked color based on light direction. This could be useful for adding color based on time of day or simply to change the ramp of color in a light so that you can open up the shadow areas with hue rather than just going dark. The test I made in the Unity plug-in Shader Forge takes a normal map and layers color over the mesh based on the direction of the light. For this test, I used a simple white directional light aimed at three spheres with the light mask shader on them. The highlight area where the light hits is rendered with blue, where the shadow areas render with red. The rim light renders in yellow and is masked to the shadow areas of the sphere so as to not just outline the mesh. The colors for the highlight, shadow, and rim light are controlled in the inspector as are the rim light power and thickness. 
The light mask shader shown with a single white directional light aimed at the spheres. Blue, red, and yellow are replacing the highlight, shadow, and rim light for the mesh.
The Shader Forge node tree for the light mask shader with control over color on hightlight, shadow, and rim light as well as control over power and thickness of the rim light. A diffuse color map can easily be added to blend with the light color if needed.
Light Mask Shader
Published:

Light Mask Shader

Masking color by light direction

Published:

Creative Fields